<template>
<div class="main">

  <div class="loginBox">
    <h2>Login</h2>
    <form action="javascript:;">
      <div class="item">
        <input type="text" v-model="username" required />
        <label>UserName</label>
      </div>
      <div class="item">
        <input type="password" v-model="password" required />
        <label>PassWord</label>
      </div>
      <button class="btn" @click="submitLogin">
        submit
        <span></span>
        <span></span>
        <span></span>
        <span></span>
      </button>
    </form>
  </div>
</div>
</template>

<script>
import { login } from "@/api/login.js";
export default {
  name: "Login",
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    submitLogin() {
      console.log(this.username + "\n" + this.password);
      login(this.username, this.password).then((res) => {
        console.log(res);
        localStorage.setItem("Token", res.data.tokenHead + res.data.token);
        this.$router.push('/home')
        this.$router.go(0)
      });
    },
  },
};
</script>

<style>
* {
  margin: 0;
  padding: 0;
}
a {
  text-decoration: none;
}
input,
button {
  background: transparent; /*背景颜色为透明*/
  border: none; /*除去默认的边框*/
  outline: none; /*获取到光标时轮廓*/
}
.main {
  height: 100vh;
  background: linear-gradient(#141e30, #243b55); /*背景颜色的多个颜色的组合*/
  display: flex; /*只对亲儿子有作用，弹性布局，在弹性布局中的都是行内*/
  justify-content: center; /* 如果盒子的布局市flex可以让盒子有空白 相当于水平居中*/
  align-items: center; /*让display：flex的元素进行垂直居中*/
  font-size: 16px;
  color: #03e9f4;
}
.loginBox {
  width: 400px;
  height: 364px;
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0px 15px 25px 0px rgba(0, 0, 0, 0.6); /*这个是阴影*/
  padding: 40px;
  box-sizing: border-box;
}
h2 {
  text-align: center;
  color: #fff;
  margin-bottom: 30px;
}
.item {
  height: 45px;
  border-bottom: 1px solid #ffffff;
  margin-bottom: 40px;
  position: relative;
}

.item input {
  width: 100%;
  height: 100%;
  color: #fff;
  padding-top: 20px;
  box-sizing: border-box;
}
.item input:focus + label,
.item input:valid + label {
  top: 0px;
  font-size: 12px;
}
.item label {
  position: absolute;
  left: 0px;
  top: 12px;
  transition: all 0.5s linear; /*这个是在本元素发生变化时添加一个动画的效果，是一个过度*/
}
.btn {
  box-sizing: border-box;
  padding: 10px 20px;
  margin-top: 30px;
  color: #03e9f4;
  overflow: hidden;
  position: relative;
  text-transform: uppercase;
  /*文本字体之间的距离*/
  letter-spacing: 2px;
}
.btn:hover {
  background: #03e9f4;
  border-radius: 5px;
  color: #fff;
  /*阴影*/
  box-shadow: 0 0 5px 0 #03e9f4, 0 0 25px 0 #03e9f4, 0 0 75px 0 #03e9f4,
    0 0 100px 0 #03e9f4;
}
.btn > span {
  position: absolute;
}
.btn > span:nth-child(1) {
  width: 100%;
  height: 2px;
  background: -webkit-linear-gradient(left, transparent, #03e9f4);
  left: -100%;
  top: 0px;
  animation: line1 1s linear infinite;
}
@keyframes line1 {
  50%,
  100% {
    left: 100%;
  }
}
.btn > span:nth-child(2) {
  width: 2px;
  height: 100%;
  background: -webkit-linear-gradient(top, transparent, #03e9f4);
  right: 0px;
  top: -100%;
  animation: line2 1s 0.25s linear infinite;
}
@keyframes line2 {
  50%,
  100% {
    top: 100%;
  }
}
.btn > span:nth-child(3) {
  width: 100%;
  height: 2px;
  background: -webkit-linear-gradient(left, #03e9f4, transparent);
  right: -100%;
  bottom: 0px;
  animation: line3 1s 0.5s linear infinite;
}
@keyframes line3 {
  50%,
  100% {
    right: 100%;
  }
}
.btn > span:nth-child(4) {
  width: 2px;
  height: 100%;
  background: -webkit-linear-gradient(top, #03e9f4, transparent);
  left: 0px;
  bottom: -100%;
  animation: line4 1s 0.75s linear infinite;
}
@keyframes line4 {
  50%,
  100% {
    bottom: 100%;
  }
}
</style>